using System;
using System.Collections.Generic;
using System.Text;

using System.Windows.Forms;

namespace FeatureWally.Client.UI.Controls {
    public class FWNodeScope : TreeNode {
        private string _stsAdm = null;

        public FWNodeScope(string text, int imageindex)
            : base(text, imageindex, imageindex) {
        }

        public string GetStsAdm(bool includeHeader, bool activate, bool uninstall) {
            StringBuilder result = new StringBuilder();
            if (includeHeader) {
                result.Append("REM Autogenerated STSADM commands to deactivate and uninstall features");
                result.Append("\r\nREM Copy-Paste this to a .bat file to manually execute it.");
                result.Append("\r\nREM Generated by Feature Wally");
                result.AppendFormat("\r\n\r\n@SET STSADM=\"{0}\"", Properties.Settings.Default.STSADM);
            }
            if (this.Nodes.Count > 0) {
                foreach (TreeNode featurenode in this.Nodes) {
                    if(featurenode is FWNodeFeature)
                        result.Append(((FWNodeFeature)featurenode).GetStsAdm(false, activate, uninstall));
                    if (featurenode is FWNodeFeatureError)
                        result.Append(((FWNodeFeatureError)featurenode).GetStsAdm(false, activate, uninstall));
                }
            }
            return result.ToString();
        }
    }
}
